<template>
  <div id="app">
    <!-- <nav>
      <router-link to="/">Home</router-link> |
      <router-link to="/about">About</router-link>
    </nav> -->
    <router-view />
  </div>
</template>
<script>
export default {
  mounted() {
    let beginTime = 0; //开始时间
    let differTime = 0; //时间差
    window.onunload = function () {
      differTime = new Date().getTime() - beginTime;
      if (differTime <= 2) {
        localStorage.removeItem("token");
      } else {
        console.log("这是刷新");
      }
    };
    // window.addEventListener("beforeunload", () => {
    //   localStorage.removeItem("token");
    // });
    window.onbeforeunload = function () {
      beginTime = new Date().getTime();
    };
  },
};
</script>
<style lang="scss">
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  list-style: none;
}
html,
body,
#app {
  height: 100%;
}
</style>
